/**需要先引入jQuery */

/**
 * local 本地开发环境
 * dev 服务器开发环境
 * pro 服务器生产环境
 */
var currentEnv = "pro";
var commonTradeHostName = null;
var commonManageHostName = null;

var getTradeHostName = function() {
  if (commonTradeHostName == null) {
    if (currentEnv == "pro") {
      commonTradeHostName = "https://pay.yanlight.com/trade/";
    } else if (currentEnv == "dev") {
      commonTradeHostName = "https://pay.yanlight.com/trade-dev/";
    } else {
      commonTradeHostName = "http://test.yanlight.com/trade/";
    }
  }
  return commonTradeHostName;
};

var getManageHostName = function() {
  if (commonManageHostName == null) {
    if (currentEnv == "pro") {
      commonManageHostName = "https://pay.yanlight.com/trade/manage";
    } else if (currentEnv == "dev") {
      commonManageHostName = "https://pay.yanlight.com/trade-dev-manage/";
    } else {
      commonManageHostName = "http://test.yanlight.com/trade_manage/";
    }
  }
  return commonManageHostName;
};

var isInWerXin = function() {
  return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
};

var loadingView = null;

var showCommonLoading = function() {
  loadingView = layer.load(1, {
    shade: [0.3, "#000000"]
  });
};

var hiddenCommonLoading = function() {
  if (loadingView != null) {
    layer.close(loadingView);
  }
};
